import multiprocessing


def producer(q):
    data = ['a', 'b', 'c', 'd']
    for temp in data:
        q.put(temp)
    print('生产者生产中.....', data)


def consumer(q):
    waiting = list()
    while True:
        data = q.get()
        waiting.append(data)
        if q.empty():
            break
    print('消费者消费中.....', waiting)


def main():
    q = multiprocessing.Queue()
    p1 = multiprocessing.Process(target=producer, args=(q,))
    p2 = multiprocessing.Process(target=consumer, args=(q,))
    p1.start()
    p2.start()


if __name__ == '__main__':
    main()
